import config from 'config'
import httpFetch from 'share/httpFetch'
import errorMessage from 'share/errorMessage'

export default {

  //上传图片
  handleImageUpload(formData) {
    return httpFetch.post(`${config.baseUrl}/api/upload/static/attachment`, formData)
  },

  //获取目录列表
  getMenuList() {
    return httpFetch.get(`${config.baseUrl}/api/operation/document/menu/auth`)
  },

  //获取文档详情
  getDocDetail(params) {
    return new Promise((resolve, reject) => {
      httpFetch.unsafe.get(`${config.baseUrl}/api/operation/document`, params).then(res => {
        resolve(res)
      }).catch(e => {
        errorMessage(e.response);
        reject(e)
      })
    })
  },

  //清除缓存，刷新文档
  refreshDoc() {
    return new Promise((resolve, reject) => {
      httpFetch.get(`${config.baseUrl}/api/operation/document/cache/clear`).then(res => {
        resolve(res)
      }).catch(e => {
        errorMessage(e.response);
        reject(e)
      })
    })
  },

}
